<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件下载页面</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
            background-color: #f5f5f5;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            padding: 20px;
            color: #333;
        }
        
        .container {
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            padding: 30px;
            text-align: center;
            max-width: 400px;
            width: 100%;
        }
        
        h1 {
            font-size: 24px;
            margin-bottom: 20px;
            color: #2c3e50;
        }
        
        .qrcode-container {
            margin: 30px 0;
            padding: 15px;
            background-color: white;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            display: inline-block;
        }
        
        .qrcode-container img {
            max-width: 100%;
            height: auto;
            border-radius: 4px;
        }
        
        .description {
            font-size: 16px;
            line-height: 1.6;
            color: #666;
            margin-bottom: 30px;
        }
        
        .download-btn {
            background-color: #3498db;
            color: white;
            border: none;
            padding: 12px 30px;
            font-size: 16px;
            font-weight: 500;
            border-radius: 8px;
            cursor: pointer;
            transition: background-color 0.3s ease;
            min-width: 180px;
        }
        
        .download-btn:hover {
            background-color: #2980b9;
        }
        
        .download-btn:active {
            transform: translateY(1px);
        }
        
        .wechat-notice {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.8);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            color: white;
            padding: 20px;
            display: none; /* 默认隐藏 */
        }
        
        .wechat-notice.show {
            display: flex;
        }
        
        .notice-content {
            text-align: center;
            max-width: 300px;
        }
        
        .notice-icon {
            font-size: 50px;
            margin-bottom: 20px;
            opacity: 0.8;
        }
        
        .notice-text {
            font-size: 18px;
            line-height: 1.6;
            margin-bottom: 30px;
        }
        
        .close-btn {
            background-color: transparent;
            border: 1px solid white;
            color: white;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }
        
        .close-btn:hover {
            background-color: rgba(255, 255, 255, 0.1);
        }
        
        @media (max-width: 480px) {
            .container {
                padding: 20px;
            }
            
            h1 {
                font-size: 20px;
            }
            
            .description {
                font-size: 14px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>文件下载</h1>
        
        <div class="qrcode-container">
            <!-- 这里可以替换为实际的二维码图片 -->
            <img src="data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Crect width='200' height='200' fill='%23ffffff'/%3E%3Crect width='60' height='60' fill='%23000000' x='30' y='30'/%3E%3Crect width='60' height='60' fill='%23000000' x='110' y='30'/%3E%3Crect width='60' height='60' fill='%23000000' x='30' y='110'/%3E%3Crect width='60' height='60' fill='%23000000' x='110' y='110'/%3E%3C/svg%3E" alt="下载二维码" id="qrcode">
        </div>
        
        <div class="description">
            <p>扫描上方二维码或点击下方按钮下载文件。</p>
            <p>温馨提示：若在微信中无法下载，请使用手机浏览器打开此页面。</p>
        </div>
        
        <button class="download-btn" id="downloadBtn">点击下载</button>
    </div>
    
    <!-- 微信提示弹窗 -->
    <div class="wechat-notice" id="wechatNotice">
        <div class="notice-content">
            <div class="notice-icon">📱</div>
            <div class="notice-text">
                <p>请使用手机浏览器打开此页面以下载文件。</p>
                <p>操作步骤：点击右上角「...」选择「在浏览器中打开」</p>
            </div>
            <button class="close-btn" id="closeNotice">我知道了</button>
        </div>
    </div>
    
    <script>
        // 配置下载链接（可根据实际需求修改）
        const downloadUrl = 'https://example.com/sample-file.pdf';
        
        // 生成二维码（这里使用的是示例，实际项目中应使用真实的二维码生成API）
        function generateQRCode() {
            // 实际项目中，应该使用如QRCode.js等库生成二维码，或调用二维码生成API
            // 这里仅作为示例，实际使用时请替换为真实的二维码生成逻辑
            console.log('二维码应包含下载链接:', downloadUrl);
            
            // 注意：实际项目中，建议使用专门的二维码生成库，如：
            // QRCode.toCanvas(document.getElementById('qrcode'), downloadUrl);
        }
        
        // 检测是否在微信浏览器中
        function isWechatBrowser() {
            const ua = navigator.userAgent.toLowerCase();
            return /micromessenger/.test(ua);
        }
        
        // 处理下载按钮点击
        function handleDownload() {
            if (isWechatBrowser()) {
                // 在微信中显示提示
                document.getElementById('wechatNotice').classList.add('show');
            } else {
                // 在其他浏览器中直接下载
                window.location.href = downloadUrl;
            }
        }
        
        // 关闭提示弹窗
        function closeNotice() {
            document.getElementById('wechatNotice').classList.remove('show');
        }
        
        // 初始化
        function init() {
            // 生成二维码
            generateQRCode();
            
            // 绑定事件监听器
            document.getElementById('downloadBtn').addEventListener('click', handleDownload);
            document.getElementById('closeNotice').addEventListener('click', closeNotice);
        }
        
        // 页面加载完成后初始化
        window.addEventListener('DOMContentLoaded', init);
    </script>
</body>
</html>